package com.aspose.cells;

import java.util.ArrayList;
import java.util.List;

class zjk {
   private SparklineGroup a;
   private zbob[] b;
   private int c;
   private int d;
   private zn e;
   private boolean f = false;
   private boolean g = false;
   private com.aspose.cells.a.d.zb h = new com.aspose.cells.a.d.zb();

   public com.aspose.cells.a.d.zb a() {
      com.aspose.cells.b.a.b.a.zi var1 = new com.aspose.cells.b.a.b.a.zi();
      float var2 = com.aspose.cells.a.d.zfq.a();
      var1.a(72.0F / var2, 72.0F / var2);
      this.h.a(var1);
      return this.h;
   }

   zjk(SparklineGroup var1, zbob[] var2, int var3, int var4) {
      this.a = var1;
      this.b = var2;
      this.c = var4;
      this.d = var3;
      this.g = false;
   }

   public void b() {
      double var1 = 0.0D;
      double var3 = 0.0D;
      double[] var5 = new double[]{var3};
      double[] var6 = new double[]{var1};
      ArrayList var7 = this.a(var5, var6);
      var3 = var5[0];
      var1 = var6[0];
      if (var3 == var1) {
         if (var3 > 0.0D) {
            var1 = 0.0D;
         } else if (var3 < 0.0D) {
            var3 = 0.0D;
         } else {
            var3 = 1.0D;
            var1 = -1.0D;
         }
      }

      boolean var8 = this.a.getType() == 2;
      if (var8) {
         var3 = 1.0D;
         var1 = -1.0D;
      }

      double var9 = 0.0D;
      if (var9 > var3) {
         var9 = var3;
      }

      if (var9 < var1) {
         var9 = var1;
      }

      byte var11 = 1;
      byte var12 = 4;
      int var13 = this.d - 2 * var11;
      int var14 = this.c - 2 * var12;
      int var15 = var7.size();
      double var16 = (double)(var13 / var15);
      float var18 = (float)(var16 * 0.7D);
      double var19 = (var3 - var9) / (var3 - var1) * (double)var14 + (double)var12;
      if (this.a.getShowHorizontalAxis() && var9 == 0.0D) {
         if (this.g) {
            com.aspose.cells.b.a.b.zm var21 = new com.aspose.cells.b.a.b.zm(Color.a(255, (Color)this.a.getHorizontalAxisColor().getColor()), 1.0F);

            try {
               this.e.b(var21, 0.0F, (float)var19, (float)this.d, (float)var19);
            } finally {
               if (var21 != null) {
                  var21.r();
               }

            }
         } else {
            float var39 = 1.0F;
            Color var22 = Color.a(255, (Color)this.a.getHorizontalAxisColor().getColor());
            com.aspose.cells.a.d.zs var23 = new com.aspose.cells.a.d.zs(var22, var39);
            com.aspose.cells.b.a.b.zo var24 = new com.aspose.cells.b.a.b.zo(0.0F, (float)var19);
            com.aspose.cells.b.a.b.zo var25 = new com.aspose.cells.b.a.b.zo((float)this.d, (float)var19);
            com.aspose.cells.a.d.zk var26 = new com.aspose.cells.a.d.zk(var24, var25);
            var26.c = var23;
            this.h.a((com.aspose.cells.a.d.zl)var26);
         }
      }

      ArrayList var40 = new ArrayList();

      int var41;
      double var48;
      for(var41 = 0; var41 < var7.size(); ++var41) {
         zave var43 = (zave)var7.get(var41);
         if (var43.d() != null) {
            double var45 = com.aspose.cells.b.a.ze.g(var43.d());
            if (var8) {
               if (var45 > 1.0D) {
                  var45 = 1.0D;
               }

               if (var45 < 0.0D) {
                  var45 = -1.0D;
               }
            }

            var48 = var16 * (double)var41 + var16 / 2.0D;
            if (this.a.getPlotRightToLeft()) {
               var48 = (double)(-var11) - var48;
            }

            double var30 = (var45 - var9) / (var3 - var1) * (double)var14;
            double var28 = var19 - var30;
            if (this.a.getType() == 0) {
               com.aspose.cells.b.a.b.zo var32 = new com.aspose.cells.b.a.b.zo((float)var48, (float)var28);
               var43.a(var32.d());
               var43.b(var32.e());
               com.aspose.cells.b.a.a.ze.a(var40, (Object)var32);
            } else if (var3 != var1) {
               float var51 = (float)(var48 - (double)(var18 / 2.0F));
               float var33 = (float)var28;
               if (var45 < 0.0D) {
                  var33 = (float)var19;
               }

               float var34 = (float)Math.abs(var30);
               if (var45 != 0.0D && var34 < 1.0F) {
                  var34 = 1.0F;
                  if (var45 < 0.0D) {
                     var33 = (float)var19;
                  } else {
                     var33 = (float)var19 - 1.0F;
                  }
               }

               if (var34 != 0.0F && var18 != 0.0F) {
                  com.aspose.cells.b.a.b.zq var35 = new com.aspose.cells.b.a.b.zq(var51, var33, var18, var34);
                  var43.a(var35);
                  Color var36 = Color.a(255, (Color)this.a.getSeriesColor().getColor());
                  this.c(var43, var36);
               }
            }
         } else {
            com.aspose.cells.b.a.a.ze.a(var40, (Object)null);
         }
      }

      if (this.a.getType() == 0) {
         if (this.g) {
            com.aspose.cells.b.a.b.a.zf var42 = this.e.e();
            this.e.a(4);
            this.a(var40, var7);
            this.e.a(var42);
         } else {
            this.a(var40, var7);
         }
      }

      var41 = -1;

      int var44;
      for(var44 = 0; var44 <= var7.size() - 1; ++var44) {
         zave var47 = (zave)var7.get(var44);
         if (var47.d() != null) {
            var41 = var44;
            break;
         }
      }

      var44 = -1;

      zave var46;
      int var49;
      for(var49 = var7.size() - 1; var49 >= 0; --var49) {
         var46 = (zave)var7.get(var49);
         if (var46.d() != null) {
            var44 = var49;
            break;
         }
      }

      for(var49 = 0; var49 < var7.size(); ++var49) {
         var46 = (zave)var7.get(var49);
         if (var46.d() != null) {
            var48 = com.aspose.cells.b.a.ze.g(var46.d());
            Color var50 = Color.getEmpty();
            if (this.a.getShowMarkers()) {
               var50 = Color.a(255, (Color)this.a.getMarkersColor().getColor());
            }

            if (this.a.getShowNegativePoints() && var48 < 0.0D) {
               var50 = Color.a(255, (Color)this.a.getNegativePointsColor().getColor());
            }

            if (this.a.getShowFirstPoint() && var49 == var41) {
               var50 = Color.a(255, (Color)this.a.getFirstPointColor().getColor());
            }

            if (this.a.getShowLastPoint() && var49 == var44) {
               var50 = Color.a(255, (Color)this.a.getLastPointColor().getColor());
            }

            if (this.a.getShowHighPoint() && var48 == var3) {
               var50 = Color.a(255, (Color)this.a.getHighPointColor().getColor());
            }

            if (this.a.getShowLowPoint() && var48 == var1) {
               var50 = Color.a(255, (Color)this.a.getLowPointColor().getColor());
            }

            if (!var50.isEmpty()) {
               this.a(var46, var50);
            }
         }
      }

   }

   public ArrayList a(double[] var1, double[] var2) {
      SparklineGroup var3 = this.a;
      zbob[] var4 = this.b;
      var2[0] = Double.MAX_VALUE;
      var1[0] = -1.7976931348623157E308D;
      ArrayList var5 = new ArrayList();
      zbob[] var6 = var4;
      int var7 = var4.length;

      for(int var8 = 0; var8 < var7; ++var8) {
         zbob var9 = var6[var8];
         zave var10 = new zave(var3.getPlotEmptyCellsType(), var9);
         com.aspose.cells.b.a.a.ze.a(var5, (Object)var10);
         double var11;
         if (var9.b == 5) {
            var11 = 0.0D;
         } else if (var9.b == 2) {
            if ("#N/A".equals(com.aspose.cells.b.a.zr.a(var9.a))) {
               continue;
            }

            var11 = 0.0D;
         } else if (var9.b == 3) {
            if (var3.getPlotEmptyCellsType() != 1) {
               continue;
            }

            var11 = 0.0D;
         } else {
            var11 = com.aspose.cells.b.a.ze.g(var9.a);
         }

         if (var11 > var1[0]) {
            var1[0] = var11;
         }

         if (var11 < var2[0]) {
            var2[0] = var11;
         }
      }

      if (var3.getVerticalAxisMinValueType() == 2) {
         var2[0] = var3.getVerticalAxisMinValue();
      }

      if (var3.getVerticalAxisMaxValueType() == 2) {
         var1[0] = var3.getVerticalAxisMaxValue();
      }

      if (var2[0] == Double.MAX_VALUE || var1[0] == -1.7976931348623157E308D) {
         var2[0] = 0.0D;
         var1[0] = 0.0D;
      }

      return var5;
   }

   private void a(ArrayList var1, ArrayList var2) {
      float var3 = zbuk.d(this.a.getLineWeight());
      if (var3 < 1.0F) {
         var3 = 1.0F;
      }

      com.aspose.cells.a.d.zs var4 = new com.aspose.cells.a.d.zs(Color.a(255, (Color)this.a.getSeriesColor().getColor()), var3);
      com.aspose.cells.b.a.b.zm var5 = new com.aspose.cells.b.a.b.zm(Color.a(255, (Color)this.a.getSeriesColor().getColor()), var3);

      try {
         ArrayList var6 = new ArrayList();

         for(int var7 = 0; var7 < var1.size(); ++var7) {
            zave var8 = (zave)var2.get(var7);
            if (!var8.c()) {
               if (var1.get(var7) != null) {
                  com.aspose.cells.b.a.a.ze.a(var6, var1.get(var7));
               } else if (this.a.getPlotEmptyCellsType() != 2) {
                  if (var6.size() > 1) {
                     com.aspose.cells.b.a.b.zo[] var9 = this.a(var6);
                     if (this.g) {
                        com.aspose.cells.b.a.b.a.ze var10 = new com.aspose.cells.b.a.b.a.ze();
                        var10.a(var9);
                        this.e.a(var5, var10);
                     } else {
                        com.aspose.cells.a.d.zn var19 = new com.aspose.cells.a.d.zn();
                        com.aspose.cells.a.d.zo var11 = com.aspose.cells.a.d.zo.a(var9, false);
                        var19.a = var4;
                        var19.a((com.aspose.cells.a.d.zl)var11);
                        this.h.a((com.aspose.cells.a.d.zl)var19);
                     }

                     var6.clear();
                  } else {
                     var6.clear();
                  }
               }
            }
         }

         if (var6.size() > 1) {
            com.aspose.cells.b.a.b.zo[] var15 = this.a(var6);
            if (this.g) {
               com.aspose.cells.b.a.b.a.ze var16 = new com.aspose.cells.b.a.b.a.ze();
               var16.a(var15);
               this.e.a(var5, var16);
            } else {
               com.aspose.cells.a.d.zn var17 = new com.aspose.cells.a.d.zn();
               com.aspose.cells.a.d.zo var18 = com.aspose.cells.a.d.zo.a(var15, false);
               var17.a = var4;
               var17.a((com.aspose.cells.a.d.zl)var18);
               this.h.a((com.aspose.cells.a.d.zl)var17);
            }

            var6.clear();
         }
      } finally {
         if (var5 != null) {
            var5.r();
         }

      }

   }

   private com.aspose.cells.b.a.b.zo[] a(List var1) {
      com.aspose.cells.b.a.b.zo[] var2 = new com.aspose.cells.b.a.b.zo[var1.size()];
      zbuk.a(var2);

      for(int var3 = 0; var3 < var1.size(); ++var3) {
         var2[var3] = (com.aspose.cells.b.a.b.zo)var1.get(var3);
      }

      return var2;
   }

   private void a(zave var1, Color var2) {
      if (this.a.getType() == 0) {
         this.b(var1, var2);
      } else {
         this.c(var1, var2);
      }

   }

   private void b(zave var1, Color var2) {
      float var3 = var1.a();
      float var4 = var1.b();
      float var5 = 3.0F;
      float var6 = (float)(this.a.getLineWeight() / 0.75D);
      if (var6 > 1.0F) {
         var5 += (var6 - 1.0F) * 1.5F;
      }

      com.aspose.cells.b.a.b.zo[] var7 = new com.aspose.cells.b.a.b.zo[4];
      zbuk.a(var7);
      int var8 = (int)(var5 / 2.0F + 0.5F);
      var7[0].a(var3 - (float)var8);
      var7[0].b(var4);
      var7[1].a(var3);
      var7[1].b(var4 - (float)var8);
      var7[2].a(var3 + (float)var8);
      var7[2].b(var4);
      var7[3].a(var3);
      var7[3].b(var4 + (float)var8);
      com.aspose.cells.b.a.b.a.ze var9 = new com.aspose.cells.b.a.b.a.ze();

      try {
         com.aspose.cells.b.a.b.zu var10 = new com.aspose.cells.b.a.b.zu(var2);

         try {
            var9.b(var7);
            if (this.g) {
               this.e.a((com.aspose.cells.b.a.b.zc)var10, (com.aspose.cells.b.a.b.a.ze)var9);
            } else {
               com.aspose.cells.a.d.zn var11 = new com.aspose.cells.a.d.zn();
               com.aspose.cells.a.d.zo var12 = com.aspose.cells.a.d.zo.a(var7, true);
               var11.a((com.aspose.cells.b.a.b.zc)var10);
               var11.a((com.aspose.cells.a.d.zl)var12);
               this.h.a((com.aspose.cells.a.d.zl)var11);
            }
         } finally {
            if (var10 != null) {
               var10.f();
            }

         }
      } finally {
         if (var9 != null) {
            var9.h();
         }

      }

   }

   private void c(zave var1, Color var2) {
      com.aspose.cells.b.a.b.zq var3 = var1.e();
      com.aspose.cells.b.a.b.zu var4 = new com.aspose.cells.b.a.b.zu(var2);
      if (this.g) {
         this.e.b((com.aspose.cells.b.a.b.zc)var4, (com.aspose.cells.b.a.b.zq)var3);
      } else {
         com.aspose.cells.a.d.zn var5 = new com.aspose.cells.a.d.zn(var3);
         var5.a((com.aspose.cells.b.a.b.zc)var4);
         this.h.a((com.aspose.cells.a.d.zl)var5);
      }

   }

   public void c() {
      this.a(true);
      com.aspose.cells.b.a.zg.a(this);
   }

   protected void a(boolean var1) {
      if (!this.f) {
         if (var1 && this.g) {
            this.e.c();
         }

         this.f = true;
      }

   }

   protected void finalize() throws Exception {
      this.c();
   }
}
